import requests
import json
url_head = 'https://www.bing.com/'
url_res = 'http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=zh-CN'

def request(url):#请求网址
    res = requests.get(url)
    return res
def Preser(url):#保存图片
    with open("必应每日一图.jpg","wb") as w:
        w.write(request(url).content) 
if __name__ == "__main__":
    url_foot = json.loads(request(url_res).text)#序列化字符串
    url = url_head + url_foot["images"][0]['url'] #拼接网址
    Preser(url)